from cluster1d import *

@demo
def asBaged() :
  for x in sorted(summed(bagged(
        [random.randint(1,10) 
         for x in range(1000)])).values()):
    print x

@demo
def bag1ed() :
  def worker(txt,x,min=1) :
    print "\n>>>> "+txt+"\n"
    for x in sorted(div(x,minObs=min).values()): print x
  worker("a",summed(bagged([1,1,1,1,1,1,1,1,2,2,2,2,2])))
  worker("b",summed({'one':[1,1,1,1,1,1,1,1],
                    'two':[2,2,2,2,2,2]}))
  worker("c",summed({'a':[1,1,1,1,1],
                      'b':[10,10,10,10,10]}))
  worker("d",summed({'a':[0.34,0.49,0.51,0.6],
                     'b1':[0.6,0.7,0.8,0.9],
                      'b2':[0.6,0.7,0.8,0.9],
                      'c':[0.1,0.2,0.3,0.4]}))
  worker("e",summed({'a': [101 ,  100  , 99  , 101,   99], 
                     'b':[ 101,   100 ,  99,   101 ,  100],
                     'c':[ 101 ,  100 ,  99 ,  101 ,  99], 
                     'd':[ 101  , 100  , 99  , 101  , 100],
                     'e':[ 101,   100 ,  99 ,  101 ,  99 ],
                     'f':[ 101 ,  100,   99 ,  101,   100]}))
  worker("f",summed({'a':[101,100,99,101,99 ],
                     'b':[101,100,199,101,100],
                     'c':[101,100,199,101,199],
                     'd':[401,400,499,401,400],
                     'e':[401,400,499,401,499],
                     'f':[401,400,409,401,400]}))
  worker("g",summed({'a' :[101 ,  100  , 99  , 101 ,  99], 
                     'b': [101 ,  100  , 199,   101 ,  100],
                     'c': [101  , 100 ,  199 ,  101,   199 ],
                     'd': [601,   600  , 699  , 601  , 600],
                     'e': [601 ,  600 ,  699 ,  601 ,  699 ],
                     'f': [601  , 600,   609  , 601,   600]}))
  worker("h",summed({'a': [1],'b':[20],'c':[20],
                      'd':[20000],'e':[600000]}))
  worker("i",summed({'a': [101.100,99,101,99],
                     'b': [101,100,99,101,100]}))
  worker("j1", summed(bagged(sorted([85	,80	, 83	,70	,
                              68	, 65	, 64	, 72	,
                              69	, 75	,   81	,
                              75,  72, 71]))))	
  worker("j4", summed(bagged(sorted([85	,80	, 83	,70	,
                              68	, 65	, 64	, 72	,
                              69	, 75	,   81	,
                              75,  72, 71]))),min=4)	
